﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentNHibernate.Mapping;
using NHibernate;
using FluentNHibernate.Data;

namespace BankCreditPortfolio.DAL.Entities
{
    public class AgreementPersistence
    {
        public virtual int AgreementId { get; set; }
        public virtual Banker Banker { get; set; }
        //public virtual Client Client { get; set; }
        public virtual Credit Credit { get; set; }
        public virtual OrderInfoPersistence Order { get; set; }
    }

    public class Agreement : AgreementPersistence
    {
        new public OrderInfo Order
        {
            get
            {
                return (OrderInfo)base.Order;
            }
            set
            {
                base.Order = value;
            }
        }
        //new public Client Client
        //{
        //    get { return (Client) base.Client; }
        //    set { base.Client = value; }
        //}
    }

    public class AgreementMap : ClassMap<AgreementPersistence>
    {
        public AgreementMap()
        {
            Id(x => x.AgreementId).GeneratedBy.HiLo("agreement");
            Id(x => x.AgreementId).Unique();
            References(x => x.Banker).Column("BankerId");
            //References(x => x.Client).Column("ClientId");
            References(x => x.Credit).Column("CreditId");
            References(x => x.Order).Column("OrderId");
            Table("Agreement");
        }
    }
}
